﻿#region Header
// ------------------------ Licence / Copyright ------------------------
// 
// ScrumTable for Scrum Meeting Support
// Copyright © HSR - Hochschule für Technik Rapperswil
// All Rights Reserved
// 
// Author:
//  Michael Gfeller Silvan Gehrig Patrick Boos
// 
// ---------------------------------------------------------------------
#endregion

#region Usings

using ScrumTable.Common.Collections;

#endregion

namespace ScrumTable.DL.Data.Common.Serialization
{
    /// <summary>
    /// Represents an index entry for the a new DataObject to insert. 
    /// </summary>
    public class DataObjectIndexEntry<T>
    {
        #region Declarations
        //--------------------------------------------------------------------
        // Declarations
        //--------------------------------------------------------------------

        #endregion

        #region Properties
        //--------------------------------------------------------------------
        // Properties
        //--------------------------------------------------------------------

        /// <summary>
        /// Gets the unique index which can be used as the internal id.
        /// </summary>
        public int Index { get; private set; }

        /// <summary>
        /// Gets/sets the associated new created data layer object of type T.
        /// </summary>
        public T DataLayerObject { get; set; }

        /// <summary>
        /// Gets/sets the full id chain of the data layer object.
        /// </summary>
        internal ValueChain<string> DataLayerObjectIds { get; set; }

        /// <summary>
        /// Gets the full id chain of the original (raw) deserialized object.
        /// </summary>
        public ValueChain<string> RawDataObjectIds { get; private set; }

        /// <summary>
        /// Gets the original (raw) deserialized object.
        /// </summary>
        public DataObject RawDataObject { get; private set; }

        /// <summary>
        /// Gets the parent DataAccessObject which contains the RawDataObject.
        /// </summary>
        internal DataAccessObject RawParent { get; private set; }

        /// <summary>
        /// Gets the value chain of the parent elements.
        /// </summary>
        internal ValueChain<string> RawParentIds { get; private set; }

        #endregion

        #region Constructors / Destructor
        //--------------------------------------------------------------------
        // Constructors / Destructor
        //--------------------------------------------------------------------

        internal DataObjectIndexEntry(int index, DataAccessObject parent, ValueChain<string> parentIds, DataObject toIndex, ValueChain<string> toIndexIds)
        {
            Index = index;

            RawParent = parent;
            RawParentIds = parentIds;

            RawDataObject = toIndex;
            RawDataObjectIds = toIndexIds;
        }

        #endregion

        #region Methods
        //--------------------------------------------------------------------
        // Methods
        //--------------------------------------------------------------------

        /// <summary>
        /// Returns a <see cref="System.String"/> that represents this instance.
        /// </summary>
        /// <returns>
        /// A <see cref="System.String"/> that represents this instance.
        /// </returns>
        public override string ToString()
        {
            return string.Format("{0} {1}", base.ToString(), RawDataObjectIds);
        }

        #endregion

        #region Events
        //--------------------------------------------------------------------
        // Events
        //--------------------------------------------------------------------

        #endregion
    }
}